package com.tofacebook.proxy.service.impl;

import com.tofacebook.proxy.mapper.EmpMapper;
import com.tofacebook.proxy.model.Emp;
import com.tofacebook.proxy.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 员工的实现类
 * 既然是接口的实现类  需要添加@Service 将其存放到spring IOC容器里面去管理
 */
@Service
@Slf4j
public class EmpServiceImpl implements EmpService {

    /*引入我们Mapper接口*/
    @Autowired
    private EmpMapper empMapper;

    public int saveEmpInfo(Emp emp) {
        int num = empMapper.saveEmpInfo(emp);
        if(num>0){
            log.info("保存数据成功：{}",emp);
        }
        return num;
    }

    public Emp queryEmpByEmpId(Long empId) {
        Emp emp = empMapper.queryEmpByEmpId(empId);
        log.info("获取员工信息：{}",emp);
        return emp;
    }
}
